package com.cqcvc.controller;

import com.cqcvc.pojo.DownLog;
import com.cqcvc.service.DownLogService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Controller
public class DownLogController {
    @Autowired
    private DownLogService downLogService;

    @RequestMapping("chart")
    @ResponseBody
    public Map<String,Object> stas(){
        Map<String,Object> map=new HashMap<>();
        List<DownLog> list=downLogService.stas();
        String[] btArr=new String[list.size()]; //用于存放标题
        Integer[] numArr=new Integer[list.size()]; //用于存放下载次数
        int i=0;
        for (DownLog dl:list){
            btArr[i]=dl.getTitle();
            numArr[i]=dl.getNum();
            i++;
        }
        map.put("bts",btArr);  //将两个数组放入map对象
        map.put("nums",numArr);
        return map;
    }

}
